package com.zmn.oms.services.impl.account;

import com.zmn.common.utils.number.NumberUtil;
import com.zmn.oms.model.entity.account.OrderAccountResult;
import com.zmn.oms.persistence.interfaces.account.OrderAccountResultDao;
import com.zmn.oms.services.interfaces.account.OrderAccountResultService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * 描述：算账结果保存查询Service
 *
 * @author xiewenbing
 * @since 2022/8/16 17:52
 */
@Service
public class OrderAccountResultServiceImpl implements OrderAccountResultService {

    @Resource
    private OrderAccountResultDao orderAccountResultDao;

    /**
     * 根据工单id查找
     * @param workId
     * @return
     */
    @Override
    public OrderAccountResult findByKey(Long workId) {
        if (NumberUtil.isNullOrZero(workId)) {
            return null;
        }

        return orderAccountResultDao.findByKey(workId);
    }

    /**
     * 更新数据
     * @param orderAccountResult
     */
    @Override
    public void updateByKey(OrderAccountResult orderAccountResult) {
        if (Objects.isNull(orderAccountResult)) {
            return;
        }

        orderAccountResultDao.updateByKey(orderAccountResult);
    }

    /**
     * 插入数据
     * @param orderAccountResult
     */
    @Override
    public void insert(OrderAccountResult orderAccountResult) {
        if (Objects.isNull(orderAccountResult)) {
            return;
        }

        orderAccountResultDao.insert(orderAccountResult);
    }

    /**
     * 删除数据
     * @param workId
     */
    @Override
    public void deleteByKey(Long workId) {
        if (NumberUtil.isNullOrZero(workId)) {
            return;
        }

        orderAccountResultDao.deleteByKey(workId);
    }
}
